<?php
/**
 * A base model that can generate uuid when creating
 *
 * Author: JennyWang
 * Date: 2018/4/11
 * Time: 21:36
 * Created by PhpStorm.
 */
namespace App\Models\Concerns;

use Illuminate\Database\Eloquent\Model;
use Ramsey\Uuid\Uuid;

/**
 * @property string uuid
 */
class UuidModel extends Model
{
    /**
     * Boot the Model.
     */
    public static function boot()
    {
        parent::boot();
    
        static::creating(function (UuidModel $model) {
            $model->uuid = Uuid::uuid4()->toString();
        });
    }
    
}